import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

//解决重复导航的问题
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/Login.vue'),
    meta: { title: '登录' }
  },
  {
    path: '/home',
    component: () => import('../views/Home.vue'),
    children: [
      {
        path: '', name: 'home',
        redirect: '/home/all'
      },
      /*  {
         path: 'document',
         component: () => import('../components/Home/document/all.vue'),
         children: [ */
      /*  {
         path: '', name: 'document',
         redirect: '/home/document/all'
       }, */
      {
        path: 'all',
        name: 'all',
        component: () => import('../components/Home/document/all.vue'),
        meta: { title: '全部文件' },
      },
      {
        path: 'classify/:type',
        name: 'classify',
        component: () => import('../components/Home/document/classfiy.vue'),
        meta: { title: '' },
      },

      /* ]
    } */
    ]
  },
  {
    path: '/s',
    name: 'shareLink',
    component: () => import('../views/Share.vue'),
    meta: { title: '分享链接' },
  }

]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
